package com.ty.day5;

import java.util.Arrays;
import java.util.Random;
import java.util.Scanner;

/**
 * Created by IntelliJ IDEA.
 *
 * @author : txy
 * @create : 2023/11/10 18:13
 */
public class Task2 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] redBall = new int[0];
        Random random = new Random();
        int x;
        for (int i = 0; i < 6; i++) {
            x = random.nextInt(32) + 1;
            if (isRepetition(x, redBall)) {
                redBall = Arrays.copyOf(redBall, redBall.length + 1);
                redBall[redBall.length - 1] = x;
            } else {
                i--;
            }
        }
        int blueBall = random.nextInt(7) + 1;
        String blueB="[ 0"+blueBall+" ]";
        String redB = "[ ";
        for (int i : redBall) {
            if (i < 10) {
                redB += "0" + i + " ";
            } else {
                redB += i + " ";
            }
        }
        redB=redB+"]";
        System.out.println("红球号码：" + redB);
        System.out.println("蓝球号码：" + blueB);

    }

    public static boolean isRepetition(int x, int[] a) {
        if (a.length == 0) {
            return true;
        }
        for (int i : a) {
            if (i == x) {
                return false;
            }
        }
        return true;
    }
}
